package com.zdkj.subway.support.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zdkj.common.core.constant.CommonConstants;
import com.zdkj.common.core.util.R;
import com.zdkj.common.log.annotation.SysLog;
import com.zdkj.subway.support.entity.SwPmWorkotherHappenCause;
import com.zdkj.subway.support.service.SwPmWorkOtherHappenCauseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 其他相关数据产生原因参数表
 *
 * @author cheng
 * @date 2021-05-07 14:16:07
 */
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/swpmworkotherhappencause")
@Api(value = "swpmworkotherhappencause", tags = "其他相关数据产生原因参数表(产生原因)")
public class SwPmWorkOtherHappenCauseController {

    private final SwPmWorkOtherHappenCauseService swPmWorkOtherHappenCauseService;

    /**
     * 根据主类型查子类型参数接口
     * @param mainDataValue
     * @return
     */
    @ApiOperation(value = "根据主类型查子类型参数接口", notes = "根据主类型查子类型参数接口")
    //@SysLog("根据主类型查子类型参数接口")
    @GetMapping("/dict/{mainDataValue}")
    public R getParamByMainType(@PathVariable String mainDataValue) {
        List<SwPmWorkotherHappenCause> list = swPmWorkOtherHappenCauseService.list(Wrappers.<SwPmWorkotherHappenCause>query()
                .lambda().eq(SwPmWorkotherHappenCause::getMainDataValue, mainDataValue)
                .eq(SwPmWorkotherHappenCause::getStatus, CommonConstants.ENABLE));
        return R.ok(list);
    }

    /**
     * 根据主类型查子类型参数接口
     * @param
     * @return
     */
    @ApiOperation(value = "根据主类型查子类型参数接口", notes = "根据主类型查子类型参数接口")
    //@SysLog("根据主类型查子类型参数接口")
    @GetMapping("/dict")
    public R getParamByMainType() {
        List<SwPmWorkotherHappenCause> list = swPmWorkOtherHappenCauseService.list(Wrappers.<SwPmWorkotherHappenCause>query()
                .lambda()
                .eq(SwPmWorkotherHappenCause::getStatus, CommonConstants.ENABLE));
        return R.ok(list);
    }

    /**
     * 根据主类型查子类型参数接口
     * @param happenCause
     * @return
     */
    @ApiOperation(value = "根据主类型查子类型参数接口", notes = "根据主类型查子类型参数接口")
    //@SysLog("根据主类型查子类型参数接口")
    @GetMapping("/getHappenCause")
    public R getHappenCause(String happenCause) {
        SwPmWorkotherHappenCause cause = swPmWorkOtherHappenCauseService.getOne(Wrappers.<SwPmWorkotherHappenCause>query()
                .lambda().eq(SwPmWorkotherHappenCause::getSubDataValue, happenCause)
                .eq(SwPmWorkotherHappenCause::getStatus, CommonConstants.ENABLE));
        return R.ok(cause);
    }


}
